package com.yunhe.authority.controller.authority;

import com.yunhe.authority.domain.authority.*;
import com.yunhe.authority.service.authority.TokenService;
import com.yunhe.authority.service.authority.UserService;
import com.yunhe.authority.util.MyHeaderUtil;
import com.yunhe.common.annotation.OperationRecord;
import com.yunhe.common.constant.SystemConsts;
import com.yunhe.common.exception.ArgumentErrorException;
import com.yunhe.common.exception.ObjectNotFoundException;
import com.yunhe.common.exception.UniqueConstraintsException;
import com.yunhe.common.exception.UsernamePasswordException;
import com.yunhe.common.model.PageParam;
import com.yunhe.common.model.ResultObject;
import com.yunhe.common.util.CollectionUtil;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.*;

/**
 * 用户Controller
 * @author liuronglei
 */
@Api(value = "user", description = "用户维护", tags = {"Authority_User"})
@RestController
@RequestMapping("/users")
public class UserController {
    @Autowired
    private UserService userService;
    @Autowired
    private MyHeaderUtil myHeaderUtil;

    @Autowired
    private TokenService tokenService;

    /**
     * 新增用户
     */
    @ApiOperation("获取当前登录用户信息")
    @RequestMapping(value = "/logout",method = RequestMethod.GET)
    public ResponseEntity<ResultObject> Logout() throws ArgumentErrorException {
        User headerUser = myHeaderUtil.getHeaderUser();
        if(headerUser ==null){
            throw new ArgumentErrorException("登录信息已失效,请重新登录");
        }
        User user  = userService.findByPhoneAndDecodePassword(headerUser.getPhone(),headerUser.getPassword());
        if(user ==null){
            throw new ArgumentErrorException("登录信息已失效,请重新登录");
        }
        String lostToken = tokenService.lostToken(user);
        Map<String, Object> result = new HashMap<>();
        result.put("token", lostToken);
        return new ResponseEntity<>(new ResultObject<>(result), HttpStatus.OK);
    }

    /**
     * 新增用户
     */
    @ApiOperation("获取当前登录用户信息")
    @RequestMapping(value = "/getCurrentLoginUser",method = RequestMethod.GET)
    public ResponseEntity<ResultObject> getCurrentLoginUser() throws ArgumentErrorException {
        User headerUser = myHeaderUtil.getHeaderUser();
        if(headerUser ==null){
            throw new ArgumentErrorException("登录信息已失效,请重新登录");
        }
        User user  = userService.findByPhoneAndDecodePassword(headerUser.getPhone(),headerUser.getPassword());
        if(user ==null){
            throw new ArgumentErrorException("登录信息已失效,请重新登录");
        }
        //设置对应的项目
        List<ProjectData> projectDatas = findStationByLoginUser(headerUser);
        if(!CollectionUtil.isEmpty(projectDatas)){
            projectDatas.stream().forEach(projectData -> {
                if(projectData.getId().equals(user.getLastAccessProject())){
                    user.setLastAccessProjectTitle(projectData.getTitle());
                }
            });
        }
        return new ResponseEntity<>(new ResultObject<>(user), HttpStatus.OK);
    }

    private List<ProjectData> findStationByLoginUser(User user) {
        List<ProjectData> result = new ArrayList<>();
        //判断当前登录的账号是单位账号还是园区账号
        List<Firm> firms = user.getFirms();
        List<Station> stations = user.getStations();
        if (!CollectionUtil.isEmpty(stations)) {
            for (Station station : stations) {
                ProjectData projectData = new ProjectData();
                projectData.setId(station.getId());
                projectData.setTitle(station.getEnterpriseFullName());
                projectData.setType("station");
                projectData.setSn(station.getSn());
                result.add(projectData);
            }
        }
        if (!CollectionUtil.isEmpty(firms)) {
            for (Firm firm : firms) {
                ProjectData projectData = new ProjectData();
                projectData.setId(firm.getId());
                projectData.setTitle(firm.getEnterpriseFullName());
                projectData.setType("firm");
                projectData.setSn(firm.getSn());
                result.add(projectData);
            }
        }
        //对集合针对每个ProjectData的sn首字母进行升序排序
        result.sort(Comparator.comparing(ProjectData::getSn));
        return result;
    }

    /**
     * 新增用户
     * @param user 用户对象
     */
    @ApiOperation("新增用户")
    @RequestMapping(method = RequestMethod.POST)
    @OperationRecord(menu = "用户管理", actionType = SystemConsts.ACTION.ADD)
    public ResponseEntity<ResultObject> post(@RequestParam(value = "stationId",required = false) Long stationId,
                                             @RequestParam(value = "firmId",required = false) Long firmId,
                                             @ApiParam(value = "归属部门id")  @RequestParam(value = "ascriptionOrgIds") String ascriptionOrgIds,
                                             @ApiParam(value = "协同部门id",required = false) @RequestParam(value = "orgIds",required = false) String orgIds,
                                             @RequestParam(value = "roleIds") String roleIds,
                                             @RequestBody User user)
            throws ArgumentErrorException, UniqueConstraintsException, ObjectNotFoundException {
        User headerUser = myHeaderUtil.getHeaderUser();
        if(headerUser == null){
            BackUser headerBackUser = myHeaderUtil.getHeaderBackUser();
            user.setCreator(headerBackUser.getTitle());
        }else {
            user.setCreator(headerUser.getTitle());
        }
        User newUser = userService.createUser(user,stationId,firmId,ascriptionOrgIds,orgIds,roleIds);
        return new ResponseEntity<>(new ResultObject<>(newUser), HttpStatus.OK);
    }

    /**
     * 批量新增用户
     * @param domainList 用户对象列表
     */
//    @ApiOperation("批量新增用户")
//    @RequestMapping(value = "/batch", method = RequestMethod.POST)
//    @OperationRecord(menu = "用户管理", actionType = SystemConsts.ACTION.ADD)
//    public ResponseEntity<ResultObject> batchPost(@RequestBody DomainList<User> domainList)
//            throws ArgumentErrorException, UniqueConstraintsException, ObjectNotFoundException {
//        Iterable<User> newUsers = userService.createUser(domainList.getList());
//        return new ResponseEntity<>(new ResultObject<>(newUsers), HttpStatus.OK);
//    }

    /**
     * 根据用户ID删除用户
     * @param ids 用户ID
     */
    @ApiOperation("根据用户ID删除用户")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "ids", value = "用户ID", required = true, dataType = "String", paramType = "path")
    })
    @RequestMapping(value = "/{ids}", method = RequestMethod.DELETE)
    @OperationRecord(menu = "用户管理", actionType = SystemConsts.ACTION.DELETE)
    public ResponseEntity<ResultObject> delete(@PathVariable("ids") String ids)
            throws UniqueConstraintsException, ArgumentErrorException {
        userService.deleteUser(ids);
        return new ResponseEntity<>(new ResultObject<>(null), HttpStatus.OK);
    }

    /**
     * 更新用户（更新全部字段）
     * @param id 用户ID
     * @param user 用户对象
     */
    @ApiOperation("更新用户（更新全部字段）")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "用户ID", required = true, dataType = "long", paramType = "path")
    })
    @RequestMapping(value = "/{id}", method = RequestMethod.PUT)
    @OperationRecord(menu = "用户管理", actionType = SystemConsts.ACTION.EDIT)
    public ResponseEntity<ResultObject> put(@PathVariable("id") Long id,
                                            @RequestBody User user)
            throws ArgumentErrorException, UniqueConstraintsException, ObjectNotFoundException {
        user.setId(id);
        User newUser = userService.updateUser(user);
        return new ResponseEntity<>(new ResultObject<>(newUser), HttpStatus.OK);
    }

    @ApiOperation("更新用户（更新全部字段移动端）")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "用户ID", required = true, dataType = "long", paramType = "path")
    })
    @RequestMapping(value = "/editUserById", method = RequestMethod.POST)
    @OperationRecord(menu = "用户管理", actionType = SystemConsts.ACTION.EDIT)
    public ResponseEntity<ResultObject> editUserById(@RequestBody User user)
            throws ArgumentErrorException, UniqueConstraintsException, ObjectNotFoundException {
        User newUser = userService.updateUser(user);
        return new ResponseEntity<>(new ResultObject<>(newUser), HttpStatus.OK);
    }

    /**
     * 更新用户（更新指定字段）
     * @param id 用户ID
     * @param name 账号
     * @param title 姓名
     * @param phone 电话
     * @param firmId 单位ID
     * @param homePageId 首页ID
     * @param themeId 主题ID
     * @param activity 是否可用
     */
//    @ApiOperation("更新用户（更新指定字段）")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "id", value = "用户ID", required = true, dataType = "long", paramType = "path"),
//            @ApiImplicitParam(name = "name", value = "账号", dataType = "string", paramType = "query"),
//            @ApiImplicitParam(name = "title", value = "姓名", dataType = "string", paramType = "query"),
//            @ApiImplicitParam(name = "phone", value = "电话", dataType = "string", paramType = "query"),
//            @ApiImplicitParam(name = "firmId", value = "单位ID", dataType = "long", paramType = "query"),
//            @ApiImplicitParam(name = "homePageId", value = "首页ID", dataType = "long", paramType = "query"),
//            @ApiImplicitParam(name = "themeId", value = "主题ID", dataType = "long", paramType = "query"),
//            @ApiImplicitParam(name = "activity", value = "是否可用", dataType = "Boolean", paramType = "query"),
//            @ApiImplicitParam(name = "admin", value = "是否角色管理员", dataType = "Boolean", paramType = "query")
//    })
//    @RequestMapping(value = "/{id}", method = RequestMethod.PATCH)
//    @OperationRecord(menu = "用户管理", actionType = SystemConsts.ACTION.EDIT)
//    public ResponseEntity<ResultObject> patch(@PathVariable("id") Long id,
//                                              @RequestParam("name") Optional<String> name,
//                                              @RequestParam("title") Optional<String> title,
//                                              @RequestParam("phone") Optional<String> phone,
//                                              @RequestParam("firmId") Optional<Long> firmId,
//                                              @RequestParam("homePageId") Optional<Long> homePageId,
//                                              @RequestParam("themeId") Optional<Long> themeId,
//                                              @RequestParam("activity") Optional<Boolean> activity,
//                                              @RequestParam("admin") Optional<Boolean> admin)
//            throws ArgumentErrorException, UniqueConstraintsException, ObjectNotFoundException {
//        User user = userService.updateUser(id, name.orElse(null), title.orElse(null),
//                phone.orElse(null), firmId.orElse(null), homePageId.orElse(null),
//                themeId.orElse(null), activity.orElse(null), admin.orElse(null));
//        return new ResponseEntity<>(new ResultObject<>(user), HttpStatus.OK);
//    }

    /**
     * 根据用户ID获得用户
     * @param id 用户ID
     */
    @ApiOperation("根据用户ID获得用户")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "用户ID", required = true, dataType = "long", paramType = "path")
    })
    @RequestMapping(value = "/{id}", method = RequestMethod.GET)
    public ResponseEntity<ResultObject> get(@PathVariable("id") Long id) {
        User user = userService.findByUserId(id);
        return new ResponseEntity<>(new ResultObject<>(user), HttpStatus.OK);
    }

    /**
     * 根据条件获得用户列表
     * @param phone
     * @param title
     * @param mail
     * @param activity
     * @param createStartTime
     * @param createEndTime
     * @param creator
     * @param lastLoginStartTime
     * @param lastLoginEndTime
     * @param lastLoginSystem
     * @param pageParam
     * @return
     */
    @ApiOperation("根据条件获得用户列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "phone", value = "电话", dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "title", value = "姓名", dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "mail", value = "账号", dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "activity", value = "状态 ", dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "createStartTime", value = "创建开始时间 ", dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "createEndTime", value = "创建结束时间 ", dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "creator", value = "创建人", dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "lastLoginStartTime", value = "最后登录开始时间 ", dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "lastLoginEndTime", value = "最后登录结束时间 ", dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "lastLoginSystem", value = "最后登录系统 ", dataType = "string", paramType = "query"),
    })
    @RequestMapping(method = RequestMethod.GET)
    public ResponseEntity<ResultObject> search(@RequestParam(value = "phone",required = false) String phone,
                                               @RequestParam(value = "title",required = false) String title,
                                               @RequestParam(value = "mail",required = false)  String mail,
                                               @RequestParam(value = "activity",required = false) String activity,
                                               @RequestParam(value = "createStartTime",required = false) String createStartTime,
                                               @RequestParam(value = "createEndTime",required = false) String createEndTime,
                                               @RequestParam(value = "creator",required = false) String creator,
                                               @RequestParam(value = "lastLoginStartTime",required = false) String lastLoginStartTime,
                                               @RequestParam(value = "lastLoginEndTime",required = false) String lastLoginEndTime,
                                               @RequestParam(value = "lastLoginSystem",required = false) String lastLoginSystem,
                                               @ModelAttribute PageParam pageParam) {
        Iterable<User> results = userService.getUserByCondition(phone,title,mail,activity,
                                            createStartTime,createEndTime,creator,lastLoginStartTime,
                                            lastLoginEndTime,lastLoginSystem,pageParam);
        return new ResponseEntity<>(new ResultObject<>(results), HttpStatus.OK);
    }

    /**
     * 根据单位或者项目获得用户列表
     * @param firmId
     * @param stationId
     * @param roleType
     * @param pageParam
     * @return
     */
    @ApiOperation("根据条件获得用户列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "firmId", value = "单位ID", dataType = "Long", paramType = "query"),
            @ApiImplicitParam(name = "stationId", value = "项目ID", dataType = "Long", paramType = "query"),
            @ApiImplicitParam(name = "roleType", value = "角色名称", dataType = "String", paramType = "query")
    })
    @RequestMapping(value = "/getProejctUserByCondition",method = RequestMethod.GET)
    public ResponseEntity<ResultObject> getProejctUserByCondition(
                                               @RequestParam(value = "firmId",required = false) Long firmId,
                                               @RequestParam(value = "stationId",required = false) Long stationId,
                                               @RequestParam(value = "roleTitle",required = false)  String roleTitle,
                                               @ModelAttribute PageParam pageParam) throws ArgumentErrorException {
        Iterable<EmployeeUser> results = userService.getUserByCondition(firmId,stationId,roleTitle,pageParam);
        return new ResponseEntity<>(new ResultObject<>(results), HttpStatus.OK);
    }

    @ApiOperation("单位/项目  禁用/恢复账号")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "ids", value = "用户id ",required = true, dataType = "string", paramType = "path"),
            @ApiImplicitParam(name = "firmId", value = "单位id ", dataType = "Long", paramType = "query"),
            @ApiImplicitParam(name = "stationId", value = "项目id", dataType = "Long", paramType = "query"),
            @ApiImplicitParam(name = "activity", value = "状态 ", dataType = "string", paramType = "query",example =  "1 正常  0  禁用")
    })
    @RequestMapping(value = "/disableRecoveryProjectUser/{ids}",method = RequestMethod.POST)
    public ResponseEntity<ResultObject> disableRecoveryProjectUser (@PathVariable("ids") String ids,
                                                                    @RequestParam(value = "firmId",required = false) Long firmId,
                                                                    @RequestParam(value = "stationId",required = false) Long stationId,
                                                                    @RequestParam(value = "activity",required = true) String activity) throws ArgumentErrorException {
        User headerUser = myHeaderUtil.getHeaderUser();
        if(headerUser != null){
            userService.disableRecoveryProjectUser(ids,firmId,stationId,activity,headerUser);
        }else {
            userService.disableRecoveryProjectBackUser(ids,firmId,stationId,activity,myHeaderUtil.getHeaderBackUser());
        }

        return new ResponseEntity<>(new ResultObject<>(), HttpStatus.OK);
    }


    @ApiOperation("查看项目/单位用户详情")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "用户id ", dataType = "Long",required = true, paramType = "path"),
            @ApiImplicitParam(name = "firmId", value = "单位id ", dataType = "Long", paramType = "query"),
            @ApiImplicitParam(name = "stationId", value = "项目id", dataType = "Long", paramType = "query")
    })
    @RequestMapping(value = "/getProjectUserById/{id}",method = RequestMethod.GET)
    public ResponseEntity<ResultObject> getProjectUserById (@PathVariable("id") Long id,
                                                            @RequestParam(value = "firmId",required = false) Long firmId,
                                                            @RequestParam(value = "stationId",required = false) Long stationId){
        EmployeeUser user = userService.getProjectUserById(id,firmId,stationId);
        return new ResponseEntity<>(new ResultObject<>(user), HttpStatus.OK);
    }

    @ApiOperation("编辑单位/项目用户信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "用户id ", dataType = "Long",required = true, paramType = "path"),
            @ApiImplicitParam(name = "firmId", value = "单位id ", dataType = "Long", paramType = "query"),
            @ApiImplicitParam(name = "stationId", value = "项目id", dataType = "Long", paramType = "query"),
            @ApiImplicitParam(name = "roleIds", value = "角色id", dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "ascriptionOrgIds", value = "归属组织id", required = true, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "orgIds", value = "协同组织id", dataType = "String", required = false,paramType = "query"),
            @ApiImplicitParam(name = "activity", value = "状态", dataType = "String", paramType = "query")
    })
    @RequestMapping(value = "/updateProjectUserById/{id}",method = RequestMethod.POST)
    public ResponseEntity<ResultObject> updateProjectUserById (@PathVariable("id") Long id,
                                                               @RequestParam(value = "firmId",required = false) Long firmId,
                                                               @RequestParam(value = "stationId",required = false) Long stationId,
                                                               @RequestParam(value = "roleIds",required = true) String roleIds,
                                                               @RequestParam(value = "ascriptionOrgIds",required = true) String ascriptionOrgIds,
                                                               @RequestParam(value = "orgIds",required = false) String orgIds,
                                                               @RequestParam(value = "activity",required = true) String activity,
                                                               @RequestBody User user) throws ArgumentErrorException,
            UniqueConstraintsException, ObjectNotFoundException {
        user.setId(id);
        User headerUser = myHeaderUtil.getHeaderUser();
        BackUser headerBackUser = myHeaderUtil.getHeaderBackUser();
        userService.updateProjectUserById(id,firmId,stationId,roleIds,ascriptionOrgIds,orgIds,activity,headerUser,headerBackUser,user);
        return new ResponseEntity<>(new ResultObject<>(), HttpStatus.OK);
    }

    @ApiOperation("删除单位/项目用户信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "ids", value = "用户id ", dataType = "String",required = true, paramType = "path"),
            @ApiImplicitParam(name = "firmId", value = "单位id ", dataType = "Long", paramType = "query"),
            @ApiImplicitParam(name = "stationId", value = "项目id", dataType = "Long", paramType = "query")
    })
    @RequestMapping(value = "/unbindProjectUser/{id}",method = RequestMethod.POST)
    public ResponseEntity<ResultObject> unbindProejctUser (@PathVariable("id") String ids,
                                                               @RequestParam(value = "firmId",required = false) Long firmId,
                                                               @RequestParam(value = "stationId",required = false) Long stationId)
            throws ArgumentErrorException, ObjectNotFoundException, UniqueConstraintsException {

        userService.unbindProejctUser(ids,firmId,stationId);
        return new ResponseEntity<>(new ResultObject<>(), HttpStatus.OK);
    }

    @ApiOperation("新增单位/项目用户信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "firmId", value = "单位id ", dataType = "Long", paramType = "query"),
            @ApiImplicitParam(name = "stationId", value = "项目id", dataType = "Long", paramType = "query"),
            @ApiImplicitParam(name = "ascriptionOrgIds", value = "归属组织id", required = true, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "orgIds", value = "协同组织id", required = false, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "roleIds", value = "角色id", required = true, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "activity", value = "状态", required = true, dataType = "String", paramType = "query")
    })
    @RequestMapping(value = "/addProjectUser",method = RequestMethod.POST)
    public ResponseEntity<ResultObject> addProjectUser (@RequestParam(value = "firmId",required = false) Long firmId,
                                                        @RequestParam(value = "stationId",required = false) Long stationId,
                                                        @RequestParam(value = "ascriptionOrgIds",required = true) String ascriptionOrgIds,
                                                        @RequestParam(value = "orgIds",required = false) String orgIds,
                                                        @RequestParam(value = "roleIds",required = true) String roleIds,
//                                                        @RequestParam(value = "activity",required = true) String activity,
                                                        @RequestBody User user) throws ArgumentErrorException, ObjectNotFoundException, UniqueConstraintsException {
        userService.addProjectUser(firmId,stationId,ascriptionOrgIds,orgIds,roleIds,user);
        return new ResponseEntity<>(new ResultObject<>(), HttpStatus.OK);
    }

    @ApiOperation("新增单位/项目用户信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "phone", value = "单位id ", dataType = "String", paramType = "query"),
    })
    @RequestMapping(value = "/getUserByPhone",method = RequestMethod.GET)
    public ResponseEntity<ResultObject> getUserByPhone (@RequestParam(value = "phone",required = true) String phone) throws ObjectNotFoundException, ArgumentErrorException {
        User user = userService.getUserByPhone(phone);
        if(user != null && user.getAdmin()){
            throw new ArgumentErrorException("当前账号为后台超级管理员,不能新增该用户！");
        }
        return new ResponseEntity<>(new ResultObject<>(user), HttpStatus.OK);
    }



    @ApiOperation("禁用/恢复账号")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "ids", value = "用户id ", dataType = "string", paramType = "path"),
            @ApiImplicitParam(name = "activity", value = "状态 ", dataType = "string", paramType = "query",example =  "1 正常  0  禁用"),
    })
    @RequestMapping(value = "/{ids}",method = RequestMethod.PATCH)
    public ResponseEntity<ResultObject> disableRecoveryUser (@PathVariable("ids") String ids ,
                                                              @RequestParam(value = "activity") String activity) throws ArgumentErrorException {
        User headerUser = myHeaderUtil.getHeaderUser();
        BackUser headerBackUser = myHeaderUtil.getHeaderBackUser();
        userService.disableRecoveryUser(ids,activity,headerUser,headerBackUser);
        return new ResponseEntity<>(new ResultObject<>(), HttpStatus.OK);
    }


    /**
     * 根据用户名获得用户对象
     * @param name 用户名
     */
//    @ApiOperation("根据用户名获得用户对象")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "name", value = "用户名", required = true, dataType = "string", paramType = "query"),
//    })
//    @RequestMapping(value = "/byName", method = RequestMethod.GET)
//    public ResponseEntity<ResultObject> getByName(@RequestParam("name") String name) {
//        User user = userService.findByName(name);
//        return new ResponseEntity<>(new ResultObject<>(user), HttpStatus.OK);
//    }

    /**
     * 根据单位获得用户列表
     * @param firmId 单位ID
     * @param queryData 查询条件
     */
//    @ApiOperation("根据单位获得用户列表")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "firmId", value = "单位ID", required = true, dataType = "long", paramType = "query"),
//            @ApiImplicitParam(name = "queryData", value = "查询条件", dataType = "string", paramType = "query")
//    })
//    @RequestMapping(value = "/byFirm", method = RequestMethod.GET)
//    public ResponseEntity<ResultObject> getByFirm(@RequestParam("firmId") Long firmId,
//                                                  @RequestParam("queryData") Optional<String> queryData,
//                                                  @ModelAttribute PageParam pageParam) {
//        Page<User> userList = userService.findUsersByFirmId(firmId, queryData.orElse(""), pageParam);
//        return new ResponseEntity<>(new ResultObject<>(userList), HttpStatus.OK);
//    }

    /**
     * 获得所有企业的用户列表
     * @param queryData 查询条件
     */
//    @ApiOperation("获得所有企业的用户列表")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "queryData", value = "查询条件", dataType = "string", paramType = "query")
//    })
//    @RequestMapping(value = "/byCompany", method = RequestMethod.GET)
//    public ResponseEntity<ResultObject> getAllCompanyUser(@RequestParam("queryData") Optional<String> queryData,
//                                                          @ModelAttribute PageParam pageParam) {
//        Page<User> userList = userService.getAllCompanyUser(queryData.orElse(""), pageParam);
//        return new ResponseEntity<>(new ResultObject<>(userList), HttpStatus.OK);
//    }

    /**
     * 绑定用户所属角色
     * @param id 用户ID
     * @param roleId 所属角色ID
     */
//    @ApiOperation("绑定用户所属角色")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "id", value = "用户ID", required = true, dataType = "long", paramType = "path"),
//            @ApiImplicitParam(name = "roleId", value = "角色ID", required = true, dataType = "long", paramType = "path")
//    })
//    @RequestMapping(value = "/{id}/roles/{roleId}", method = RequestMethod.POST)
//    public ResponseEntity<ResultObject> bindRole(@PathVariable("id") Long id,
//                                                 @PathVariable("roleId") Long roleId)
//            throws DatabaseProcessException {
//        userService.bindRole(id, roleId);
//        return new ResponseEntity<>(new ResultObject<>(null), HttpStatus.OK);
//    }

//    public ResponseEntity<ResultObject> updateRoleAdmin(@PathVariable("systemId") Long systemId,
//                                                        @PathVariable("id") Long id,
//                                                        @PathVariable("roleId") Long roleId) {
//        userService.updateRoleAdmin(id, roleId);
//        return new ResponseEntity<>(new ResultObject<>(null), HttpStatus.OK);
//    }

    /**
     * 解绑用户所属角色
     * @param id 用户ID
     * @param roleId 所属角色ID
     */
//    @ApiOperation("解绑用户所属角色")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "id", value = "用户ID", required = true, dataType = "long", paramType = "path"),
//            @ApiImplicitParam(name = "roleId", value = "角色ID", required = true, dataType = "long", paramType = "path")
//    })
//    @RequestMapping(value = "/{id}/roles/{roleId}", method = RequestMethod.DELETE)
//    public ResponseEntity<ResultObject> unbindRole(@PathVariable("id") Long id,
//                                                   @PathVariable("roleId") Long roleId) {
//        userService.unbindRole(id, roleId);
//        return new ResponseEntity<>(new ResultObject<>(null), HttpStatus.OK);
//    }

    /**
     * 更新用户所属角色列表
     * @param id 用户ID
     * @param roles 角色ID（以逗号间隔）
     */
//    @ApiOperation("更新用户所属角色列表")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "id", value = "用户ID", required = true, dataType = "long", paramType = "path"),
//            @ApiImplicitParam(name = "roles", value = "角色ID（以逗号间隔）", dataType = "string", paramType = "query")
//    })
//    @RequestMapping(value = "/{id}/roles", method = RequestMethod.PUT)
//    public ResponseEntity<ResultObject> updateRoles(@PathVariable("id") Long id,
//                                                    @RequestParam("roles") List<Long> roles)
//            throws ArgumentErrorException {
//        userService.updateRole(id, roles);
//        return new ResponseEntity<>(new ResultObject<>(null), HttpStatus.OK);
//    }

    /**
     * 更新用户绑定的首页
     * @param id 用户ID
     * @param homePageId 首页对象ID
     */
//    @ApiOperation("更新用户绑定的首页")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "id", value = "用户ID", required = true, dataType = "long", paramType = "path"),
//            @ApiImplicitParam(name = "homePageId", value = "首页对象ID", dataType = "long", paramType = "query")
//    })
//    @RequestMapping(value = "/{id}/homePages", method = RequestMethod.PUT)
//    public ResponseEntity<ResultObject> updateHomepages(@PathVariable("id") Long id,
//                                                        @RequestParam("homePageId") Long homePageId)
//            throws ObjectNotFoundException {
//        userService.updateHomePage(id, homePageId);
//        return new ResponseEntity<>(new ResultObject<>(null), HttpStatus.OK);
//    }

    /**
     * 更新用户绑定的主题
     * @param id 用户ID
     * @param themeId 主题ID
     */
//    @ApiOperation("更新用户绑定的主题")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "id", value = "用户ID", required = true, dataType = "long", paramType = "path"),
//            @ApiImplicitParam(name = "themeId", value = "主题ID", required = true, dataType = "long", paramType = "query")
//    })
//    @RequestMapping(value = "/{id}/themes", method = RequestMethod.PUT)
//    public ResponseEntity<ResultObject> updateThemes(@PathVariable("id") Long id,
//                                                     @RequestParam("themeId") Long themeId)
//            throws ObjectNotFoundException {
//        userService.updateTheme(id, themeId);
//        return new ResponseEntity<>(new ResultObject<>(null), HttpStatus.OK);
//    }

    /**
     * 修改密码
     * @param id 用户ID
     * @param password 用户密码
     */
    @ApiOperation("修改密码")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "用户ID", required = true, dataType = "long", paramType = "path"),
            @ApiImplicitParam(name = "phone", value = "手机号", required = true, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "password", value = "旧密码", required = true, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "newPassword", value = "新密码", required = true, dataType = "string", paramType = "query")
    })
    @RequestMapping(value = "/{id}/password", method = RequestMethod.PUT)
    @OperationRecord(menu = "修改密码", actionType = SystemConsts.ACTION.EDIT, action = "修改密码")
    public ResponseEntity<ResultObject> updatePassword(@PathVariable("id") Long id,
                                                       @RequestParam("phone") String phone,
                                                       @RequestParam("password") String password,
                                                       @RequestParam("newPassword") String newPassword)
            throws UsernamePasswordException {
        User user = userService.updatePassword(id, phone, password, newPassword);
        return new ResponseEntity<>(new ResultObject<>(user), HttpStatus.OK);
    }

    @ApiOperation("修改密码")
    @RequestMapping(value = "/updatePasswordByValidateCode", method = RequestMethod.POST)
    @OperationRecord(menu = "修改密码", actionType = SystemConsts.ACTION.EDIT, action = "修改密码")
    public ResponseEntity<ResultObject> updatePasswordByValidateCode(@RequestBody ChangePassword changePassword)
            throws UsernamePasswordException, ArgumentErrorException {
        User user = userService.updatePasswordByValidateCode(changePassword);
        return new ResponseEntity<>(new ResultObject<>(user), HttpStatus.OK);
    }

    /**
     * 重置密码
     * @param ids 用户ID
     */
    @ApiOperation("重置密码")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "ids", value = "用户IDs", required = true, dataType = "String", paramType = "path")
    })
    @RequestMapping(value = "/resetPassword/{ids}", method = RequestMethod.PUT)
    public ResponseEntity<ResultObject> resetPassword(@PathVariable("ids") String ids)
            throws UsernamePasswordException, ArgumentErrorException {
         List<User> users =  userService.resetPassword(ids);
        return new ResponseEntity<>(new ResultObject<>(users), HttpStatus.OK);
    }

    @ApiOperation("添加关联项目")
    @RequestMapping(value = "/bindProejctRoleOrg", method = RequestMethod.POST)
    public ResponseEntity<ResultObject> bindStationRoleOrg(@RequestBody AssociatedProjects associatedProjects)
            throws ArgumentErrorException, ObjectNotFoundException {
        userService.bindProejctRoleOrg(associatedProjects.getUserId(),associatedProjects.getFirmId(),
                associatedProjects.getStationId(),associatedProjects.getAscriptionOrgIds(),associatedProjects.getOrgIds(),
                associatedProjects.getRoleIds());
        return new ResponseEntity<>(new ResultObject<>(), HttpStatus.OK);
    }

    @ApiOperation("通过用户id 查询关联项目列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "用户ID", required = true, dataType = "Long", paramType = "path"),
            @ApiImplicitParam(name = "type", value = "类型", required = true, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "name", value = "项目id", required = false, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "title", value = "账号名称", required = false, dataType = "String", paramType = "query")
    })
    @RequestMapping(value = "/{id}/getUser", method = RequestMethod.GET)
    public ResponseEntity<ResultObject> getUser(@PathVariable("id") Long id,
                                                @RequestParam(value = "type",required = true) String type,
                                                @RequestParam(value = "keywords",required = false) String keywords,
                                                @ModelAttribute PageParam pageParam)
            throws ArgumentErrorException, ObjectNotFoundException {
        Iterable<ProjectUser> results = userService.getUser(id,type,keywords,pageParam);
        return new ResponseEntity<>(new ResultObject<>(results), HttpStatus.OK);
    }

    @ApiOperation("移除用户")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "用户ID", required = true, dataType = "Long", paramType = "path"),
            @ApiImplicitParam(name = "stationId", value = "项目id", required = false, dataType = "Long", paramType = "query"),
            @ApiImplicitParam(name = "firmId", value = "单位id", required = false, dataType = "Long", paramType = "query")
    })
    @RequestMapping(value = "/{id}/unbindUser", method = RequestMethod.POST)
    public ResponseEntity<ResultObject> unbindUser(@PathVariable("id") Long id,
                                                @RequestParam(value = "stationId",required = false) Long stationId,
                                                @RequestParam(value = "firmId",required = false) Long firmId)
            throws ArgumentErrorException, ObjectNotFoundException, UniqueConstraintsException {
        userService.unbindUser(id,stationId,firmId);
        return new ResponseEntity<>(new ResultObject<>(), HttpStatus.OK);
    }

    @ApiOperation("查询角色为业务员列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "roleType", value = "角色编码", required = true, dataType = "Long", paramType = "path")
    })
    @RequestMapping(value = "/getUserByRoleType/{roleType}", method = RequestMethod.GET)
    public ResponseEntity<ResultObject> getUserByRoleType(@PathVariable("roleType") String roleType)
            throws ArgumentErrorException, ObjectNotFoundException {
        List<User> users = userService.getUserByRoleType(roleType);
        return new ResponseEntity<>(new ResultObject<>(users), HttpStatus.OK);
    }

    @ApiOperation("根据部门查询指定角色的人员信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "stationId", value = "项目id", required = false, dataType = "Long", paramType = "query"),
            @ApiImplicitParam(name = "firmId", value = "单位id", required = false, dataType = "Long", paramType = "query"),
            @ApiImplicitParam(name = "orgId", value = "组织id", required = true, dataType = "Long", paramType = "query"),
            @ApiImplicitParam(name = "roleName", value = "角色编码", required = true, dataType = "String", paramType = "query")
    })
    @RequestMapping(value = "/getUserByOrgAndRoleName", method = RequestMethod.GET)
    public ResponseEntity<ResultObject> getUserByOrgAndRoleName(@RequestParam(value = "orgId",required = true) Long orgId,
                                                                @RequestParam(value = "roleName",required = true) String roleName,
                                                                @RequestParam(value = "stationId",required = false) Long stationId,
                                                                @RequestParam(value = "firmId",required = false) Long firmId) {
        List<UserProjectOrg> userProjectOrgs = userService.getUserByOrgAndRoleName(orgId,roleName,stationId,firmId);
        return new ResponseEntity<>(new ResultObject<>(userProjectOrgs), HttpStatus.OK);
    }

    @ApiOperation("根据部门查询指定角色的人员信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "stationId", value = "项目id", required = true, dataType = "Long", paramType = "query"),
            @ApiImplicitParam(name = "orgIds", value = "组织id", required = true, dataType = "Long", paramType = "query"),
            @ApiImplicitParam(name = "roleName", value = "角色编码", required = true, dataType = "String", paramType = "query")
    })
    @RequestMapping(value = "/getUserByStationIdAndOrg", method = RequestMethod.GET)
    public ResponseEntity<ResultObject> getUserByStationIdAndOrg(@RequestParam(value = "orgIds",required = true) List<Long> orgIds,
                                                                @RequestParam(value = "roleName",required = true) String roleName,
                                                                @RequestParam(value = "stationId",required = true) Long stationId) {
        return new ResponseEntity<>(new ResultObject<>(userService.getUserByStationIdAndOrg(orgIds,roleName,stationId)), HttpStatus.OK);
    }

    @ApiOperation("根据部门查询人员信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "orgId", value = "组织id", required = true, dataType = "Long", paramType = "query"),
    })
    @RequestMapping(value = "/getUserByOrgId", method = RequestMethod.GET)
    public ResponseEntity<ResultObject<List<Map<String,Object>>>> getUserByOrgId(@RequestParam(value = "orgId",required = true) Long orgId) throws ArgumentErrorException {
        return new ResponseEntity(new ResultObject<>(userService.getUserByOrgId(orgId)), HttpStatus.OK);
    }

    @ApiOperation("根据部门查询人员信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "orgId", value = "组织id", required = true, dataType = "Long", paramType = "query"),
    })
    @RequestMapping(value = "/getUserByOrgIdAndStationId", method = RequestMethod.GET)
    public ResponseEntity<ResultObject<List<UserProjectOrg>>> getUserByOrgIdAndStationId(@RequestParam(value = "orgId",required = true) Long orgId,
                                                                                            @RequestParam(value = "stationId",required = true) Long stationId) throws ArgumentErrorException {
        return new ResponseEntity(new ResultObject<>(userService.getUserByOrgIdAndStationId(orgId,stationId)), HttpStatus.OK);
    }


    @ApiOperation("根据条件获得用户列表")
    @GetMapping(value = "/findStationUserByStationId")
    public ResponseEntity<ResultObject<List<User>>> findStationUserByStationId(@RequestParam(value = "stationId",required = true) Long stationId) throws ArgumentErrorException {
        List<User> results = userService.findStationUserByStationId(stationId);
        return new ResponseEntity<>(new ResultObject<>(results), HttpStatus.OK);
    }

    @ApiOperation("根据条件获得用户列表")
    @GetMapping(value = "/findStationUserByQueryCondition")
    public ResponseEntity<ResultObject<List<User>>> findStationUserByQueryCondition(@RequestParam(value = "userName",required = false) String userName) throws ArgumentErrorException {
        List<User> results = userService.findStationUserByQueryCondition(userName);
        return new ResponseEntity<>(new ResultObject<>(results), HttpStatus.OK);
    }


    /**
     * 根据用户ID获得其所属角色列表
     * @param id 用户ID
     */
//    @ApiOperation("根据用户ID获得其所属角色列表")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "id", value = "用户ID", required = true, dataType = "long", paramType = "path")
//    })
//    @RequestMapping(value = "/{id}/roles", method = RequestMethod.GET)
//    public ResponseEntity<ResultObject> getRoles(@PathVariable("id") Long id) {
//        Iterable<Role> roles = userService.findRolesByUserId(id);
//        return new ResponseEntity<>(new ResultObject<>(roles), HttpStatus.OK);
//    }

    /**
     * 根据用户ID获得其有权限的web菜单列表
     * @param id 用户ID
     */
//    @ApiOperation("根据用户ID获得其有权限的web菜单列表")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "id", value = "用户ID", required = true, dataType = "long", paramType = "path")
//    })
//    @RequestMapping(value = "/{id}/menus", method = RequestMethod.GET)
//    public ResponseEntity<ResultObject> getMenus(@PathVariable("id") Long id) {
//        Iterable<Menu> menus = userService.findMenusByUserId(id);
//        return new ResponseEntity<>(new ResultObject<>(menus), HttpStatus.OK);
//    }

    /**
     * 根据用户ID获得其有权限的app菜单列表
     * @param id 用户ID
     */
//    @ApiOperation("根据用户ID获得其有权限的app菜单列表")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "id", value = "用户ID", required = true, dataType = "long", paramType = "path")
//    })
//    @RequestMapping(value = "/{id}/appMenus", method = RequestMethod.GET)
//    public ResponseEntity<ResultObject> getAppMenus(@PathVariable("id") Long id) {
//        Iterable<Menu> menus = userService.findAppMenusByUserId(id);
//        return new ResponseEntity<>(new ResultObject<>(menus), HttpStatus.OK);
//    }

    /**
     * 根据用户ID获得绑定的首页对象
     * @param id 用户ID
     */
//    @ApiOperation("根据用户ID获得绑定的首页对象")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "id", value = "用户ID", required = true, dataType = "long", paramType = "path")
//    })
//    @RequestMapping(value = "/{id}/homePages", method = RequestMethod.GET)
//    public ResponseEntity<ResultObject> getHomePage(@PathVariable("id") Long id) {
//        HomePage homePage = userService.findHomePageByUserId(id);
//        return new ResponseEntity<>(new ResultObject<>(homePage), HttpStatus.OK);
//    }

    /**
     * 根据用户ID获得主题
     * @param id 用户ID
     */
//    @ApiOperation("根据用户ID获得主题")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "id", value = "用户ID", required = true, dataType = "long", paramType = "path")
//    })
//    @RequestMapping(value = "/{id}/themes", method = RequestMethod.GET)
//    public ResponseEntity<ResultObject> getTheme(@PathVariable("id") Long id) {
//        Theme theme = userService.findThemeByUserId(id);
//        return new ResponseEntity<>(new ResultObject<>(theme), HttpStatus.OK);
//    }

    /**
     * 根据服务名获得用户联系方式
     * @param serviceName 服务名称
     */
//    @ApiOperation("根据服务名获得用户联系方式")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "serviceName", value = "服务名称", required = true, dataType = "string", paramType = "path")
//    })
//    @RequestMapping(value = "/byServiceName/{serviceName}/phones", method = RequestMethod.GET)
//    public ResponseEntity<ResultObject> getUserPhoneByServiceName(@PathVariable("serviceName") String serviceName) {
//        Iterable<String> results = userService.findUserPhoneByServiceName(serviceName);
//        return new ResponseEntity<>(new ResultObject<>(results), HttpStatus.OK);
//    }

//    /**
//     * 发送验证码
//     * @param phone 手机号
//     */
//    @ApiOperation("发送验证码")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "phone", value = "手机号", required = true, dataType = "string", paramType = "query")
//    })
//    @RequestMapping(value = "/validate", method = RequestMethod.PUT)
//    public ResponseEntity<ResultObject> sendValidateMsg(@RequestParam("phone") String phone)
//            throws ArgumentErrorException {
//        userService.sendValidateMsg(phone);
//        return new ResponseEntity<>(new ResultObject<>(null), HttpStatus.OK);
//    }

    /**
     * 发送验证码
     * @param phone 手机号
     */
//    @ApiOperation("获取验证码")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "phone", value = "手机号", required = true, dataType = "string", paramType = "query")
//    })
//    @RequestMapping(value = "/validate", method = RequestMethod.GET)
//    public ResponseEntity<ResultObject> getValidateCode(@RequestParam("phone") String phone)
//            throws ArgumentErrorException {
//        String result = userService.getValidateCode(phone);
//        return new ResponseEntity<>(new ResultObject<>(result), HttpStatus.OK);
//    }

//    @ApiOperation("密码二次验证")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "name", value = "账号", required = true, dataType = "string", paramType = "query"),
//            @ApiImplicitParam(name = "password", value = "密码", required = true, dataType = "string", paramType = "query")
//    })
//    @RequestMapping(value = "/verification", method = RequestMethod.POST)
//    public ResponseEntity<ResultObject> verification(@RequestParam("name") String name,
//                                                     @RequestParam("password") String password)
//            throws ArgumentErrorException {
//        User result = userService.verification(name, password);
//        return new ResponseEntity<>(new ResultObject<>(result), HttpStatus.OK);
//    }
//
//    @ApiOperation("二维码二次验证")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "key", value = "键", required = true, dataType = "string", paramType = "query"),
//            @ApiImplicitParam(name = "agree", value = "是否同意", required = true, dataType = "boolean", paramType = "query")
//    })
//    @RequestMapping(value = "/verification", method = RequestMethod.PUT)
//    public ResponseEntity<ResultObject> verification(@RequestParam("userId") Long userId,
//                                                     @RequestParam("key") String key,
//                                                     @RequestParam("agree") Boolean agree)
//            throws IOException {
//        userService.verification(userId, key, agree);
//        return new ResponseEntity<>(new ResultObject<>(null), HttpStatus.OK);
//    }
//
//    @ApiOperation("获取二维码二次验证结果")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "key", value = "键", required = true, dataType = "string", paramType = "query")
//    })
//    @RequestMapping(value = "/verification", method = RequestMethod.GET)
//    public ResponseEntity<ResultObject> getVerificationResult(@RequestParam("key") String key)
//            throws IOException {
//        Map<String, Object> result = userService.getVerificationResult(key);
//        return new ResponseEntity<>(new ResultObject<>(result), HttpStatus.OK);
//    }

    /**
     * 根据姓名获得用户列表
     * @param title 姓名
     */
//    @ApiOperation("根据姓名获得用户列表")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "title", value = "姓名", required = true, dataType = "string", paramType = "query")
//    })
//    @RequestMapping(value = "/byTitleContaining", method = RequestMethod.GET)
//    public ResponseEntity<ResultObject> getByTitleContaining(@RequestParam("title") String title) {
//        Iterable<User> results = userService.findByTitleContaining(title);
//        return new ResponseEntity<>(new ResultObject<>(results), HttpStatus.OK);
//    }

    /**
     * 根据账号列表获得用户列表
     * @param nameList 账号列表
     */
//    @ApiOperation("根据账号列表获得用户列表")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "nameList", value = "账号列表（以逗号间隔）", required = true, dataType = "string", paramType = "query")
//    })
//    @RequestMapping(value = "/byNames", method = RequestMethod.GET)
//    public ResponseEntity<ResultObject> getByNames(@RequestParam("nameList") List<String> nameList) {
//        Iterable<User> results = userService.findUsersByNames(nameList);
//        return new ResponseEntity<>(new ResultObject<>(results), HttpStatus.OK);
//    }

//    @ApiOperation("根据菜单name获得用户列表")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "menuName", value = "菜单name", required = true, dataType = "string", paramType = "query")
//    })
//    @RequestMapping(value = "/byMenuName", method = RequestMethod.GET)
//    public ResponseEntity<ResultObject> findByMenuName(@RequestParam("menuName") String menuName) {
//        Iterable<User> results = userService.findByMenuName(menuName);
//        return new ResponseEntity<>(new ResultObject(results), HttpStatus.OK);
//    }
}